//
//  MineBodyView.swift
//  AirlineReservation
//
//  Created by Kevin on 2020/1/27.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class MineBodyView: UIButton {
    
    // 布局相关
    private lazy var picView = UIImageView()
    private lazy var arrowView = UIImageView(image: UIImage(named: "arrow_6x11"))
    private lazy var titleView = UILabel(title: "提示", color: COLOR_NICE, size: 14)
    
    // 赋值相关
    public var pic:String? {
        didSet {
            picView.image = UIImage(named: pic!)
        }
    }
    
    public var title:String? {
        didSet {
            titleView.text = title
        }
    }
    
    override func layoutSubviews() {
        // 图标
        picView.isUserInteractionEnabled = false
        picView.frame = CGRect(x: MARGIN10, y: (frame.height - MARGIN20) * 0.5, width: MARGIN20, height: MARGIN20)
        addSubview(picView)
        // 标题
        titleView.isUserInteractionEnabled = false
        titleView.frame = CGRect(x: picView.frame.maxX + MARGIN10, y: 0, width: MARGIN100, height: frame.height)
        addSubview(titleView)
        // 箭头
        let arrowY = (frame.height - arrowView.bounds.height) * 0.5
        arrowView.frame.origin = CGPoint(x: frame.width - arrowView.bounds.width - MARGIN10, y: arrowY)
        addSubview(arrowView)
    }
}
